Repository navigation
refactor: move the USD to PHP exchange rate into settings - #36
Merged
Huerte merged 1 commit intoOct 25, 2026
Merged
Conversation
The rate 59.41 was hardcoded in Product.price_in_peso_value under the name PHILIPPINE_PESO_TO_USD, which is the opposite direction of what it converts. settings.USD_TO_PHP_RATE now holds it, read with decouple like the other settings: it defaults to 59.41 and can be set with the USD_TO_PHP_RATE environment variable. The model reads it as usd_to_php. Displayed prices do not change. SETUP.md lists the optional variable. Tests check that the default rate gives the same peso price as before and that the model uses the rate from settings. Closes nemsu-dev-org#28
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #28
The rate 59.41 was hardcoded in
Product.price_in_peso_valueunder the namePHILIPPINE_PESO_TO_USD, which is the opposite direction of what it converts.settings.py: newUSD_TO_PHP_RATE = config('USD_TO_PHP_RATE', default='59.41', cast=Decimal), read withdecouplelike the other settings. It defaults to 59.41 and can be set from the environment.store/models.py:price_in_peso_valuereadssettings.USD_TO_PHP_RATEinto a variable namedusd_to_php, so the name matches the direction. Nothing else in the model changes, so displayed prices stay the same.SETUP.md: listsUSD_TO_PHP_RATE=59.41as an optional variable in the.envexample.I kept it small, as the issue asks; a live exchange rate would be a separate change.
How I tested it
store/tests/test_exchange_rate.py:₱594.10;override_settings(USD_TO_PHP_RATE=Decimal('50.00')), the peso price and the discounted price are 500.00, so the model really uses the setting.python manage.py checkis clean andpython manage.py testpasses (11 tests), using the dummy keys from the CI workflow.USD_TO_PHP_RATE=55.5in the environment givesDecimal('55.5')in settings.